package com.knowif.pojo;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 
 * @author wcyong
 * 
 * @date 2019-06-16
 */
public class UserItem {
    private Integer id;

    /**
     * 类目id
     */
    private Integer itemId;

    /**
     * 用户id
     */
    private Integer userId;

    /**
     * 语言类型'1托福', '2GMAT','3雅思','4GRE'
     */
    private Integer languageType;

    /**
     * 企业类型'1金融', '2咨询','3互联网','4建筑','5 4A广告','6快速消费品','7房地产','8医疗器械','9其他'
     */
    private Integer enterpriseType;

    private TutorEducationInfo tutorEducationInfo;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getItemId() {
        return itemId;
    }

    public void setItemId(Integer itemId) {
        this.itemId = itemId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getLanguageType() {
        return languageType;
    }

    public void setLanguageType(Integer languageType) {
        this.languageType = languageType;
    }

    public Integer getEnterpriseType() {
        return enterpriseType;
    }

    public void setEnterpriseType(Integer enterpriseType) {
        this.enterpriseType = enterpriseType;
    }

    public TutorEducationInfo getTutorEducationInfo() {
        return tutorEducationInfo;
    }

    public void setTutorEducationInfo(TutorEducationInfo tutorEducationInfo) {
        this.tutorEducationInfo = tutorEducationInfo;
    }

    public static List<Integer> getTutorIds(List<UserItem> userItems){
        if(userItems == null || userItems.isEmpty()){
            return new ArrayList<Integer>();
        }
        List<Integer> tutorIds = new ArrayList<Integer>();
        for(UserItem userItem : userItems){
            tutorIds.add(userItem.getUserId());
        }
        return tutorIds;
    }
    
    /**
     * @author: xingyao 
     * @Description:  得到学校ids
     * @param userItems
     * @return
     */
    public static List<Integer> getSchools(List<UserItem> userItems){
    	if(userItems == null || userItems.isEmpty()){
    		return new ArrayList<Integer>();
    	}
    	List<Integer> schools = new ArrayList<Integer>();
    	for(UserItem userItem : userItems){
    		if(userItem.getTutorEducationInfo() != null && userItem.getTutorEducationInfo().getSchoolId() != null){
    			schools.add(userItem.getTutorEducationInfo().getSchoolId());
    		}
    	}
    	return schools;
    }
    
    
    /**
     * @author: xingyao 
     * @Description:  得到学校ids
     * @param userItems
     * @return
     */
    public static List<Integer> getIds(List<UserItem> userItems){
    	if(userItems == null || userItems.isEmpty()){
    		return new ArrayList<Integer>();
    	}
    	List<Integer> ids = new ArrayList<Integer>();
    	for(UserItem userItem : userItems){
    		ids.add(userItem.getId());
    	}
    	return ids;
    }
    
    
    public static List<Integer> getSpecialIds(List<UserItem> userItems){
    	if(userItems == null || userItems.isEmpty()){
    		return new ArrayList<Integer>();
    	}
    	List<Integer> specialIds = new ArrayList<Integer>();
    	for(UserItem userItem : userItems){
    		if(userItem.getTutorEducationInfo() != null && userItem.getTutorEducationInfo().getSpecialId() != null){
    			specialIds.add(userItem.getTutorEducationInfo().getSpecialId());
    		}
    	}
    	return specialIds;
    }
    
    public static void saveTutorEducationInfo(List<UserItem> userItems,List<TutorEducationInfo> educationInfos){
    	if(userItems == null ||userItems.isEmpty() || educationInfos == null  || educationInfos.isEmpty()){
    		return;
    	}
    	for(UserItem userItem : userItems) {
    		for(TutorEducationInfo tutorEducationInfo : educationInfos){
    			if(userItem.getId()  != null && userItem.getId().equals(tutorEducationInfo.getUserItemId())){
    				userItem.setTutorEducationInfo(tutorEducationInfo);
    			}
    		}
    	}
    }
    

	@Override
	public String toString() {
		return "UserItem [id=" + id + ", itemId=" + itemId + ", userId=" + userId + ", languageType=" + languageType
				+ ", enterpriseType=" + enterpriseType + ", tutorEducationInfo=" + tutorEducationInfo + "]";
	}
    
}